rofiles-fuse: Improve error message for failure to open root
authorColin Walters <walters@verbum.org>
Tue, 2 Oct 2018 15:47:48 +0000 (11:47 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Fri, 12 Oct 2018 14:11:10 +0000 (14:11 +0000)
I was debugging some rpm-ostree work and saw:
`openat: No such file or directory`
and it wasn't immediately obvious it was stderr from `rofiles-fuse`.

Use the `err` API which is better in many ways; in this case
it automatically prefixes with `argv0`.

Closes: #1747
Approved by: jlebon

src/rofiles-fuse/main.c

index fd16e29b2cdd8e34bc682966b2aeb57ec9583b64..4033caa45b89a2ad8979cc40039ecdb532de8287 100644 (file)
@@ -25,6 +25,7 @@
 #include <sys/stat.h>
 #include <sys/statvfs.h>
 #include <stdio.h>
+#include <err.h>
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
@@ -628,10 +629,7 @@ rofs_parse_opt (void *data, const char *arg, int key,
         {
           basefd = openat (AT_FDCWD, arg, O_RDONLY | O_NONBLOCK | O_DIRECTORY | O_CLOEXEC | O_NOCTTY);
           if (basefd == -1)
-            {
-              perror ("openat");
-              exit (EXIT_FAILURE);
-            }
+            err (1, "opening rootfs %s", arg);
           return 0;
         }
       else